From: Paul Eggert Date: Mon, 29 Aug 2011 16:01:33 +0000 (-0700) Subject: * eval.c (verror): Simplify by rewriting in terms of evxprintf, X-Git-Tag: archive/raspbian/1%29.2+1-2+rpi1~1^2~324^2~2390^2~29 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:///%22http:/www.example.com/cgi/%22https:/www.github.com/%22bookmarks:/?a=commitdiff_plain;h=4ba074ae08b2348623ee620d6e7adf8ff5a8aa98;p=emacs.git * eval.c (verror): Simplify by rewriting in terms of evxprintf, which has the guts of the old verror function. --- diff --git a/src/ChangeLog b/src/ChangeLog index 80b1629359f..faeeef3c290 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -33,6 +33,9 @@ * emacs.c (main) [NS_IMPL_COCOA]: Don't overrun buffer when creating daemon; the previous buffer-overflow check was incorrect. + * eval.c (verror): Simplify by rewriting in terms of evxprintf, + which has the guts of the old verror function. + 2011-08-26 Paul Eggert Integer and memory overflow issues (Bug#9196). diff --git a/src/eval.c b/src/eval.c index e722b53fb72..f2407cede31 100644 --- a/src/eval.c +++ b/src/eval.c @@ -1951,35 +1951,11 @@ verror (const char *m, va_list ap) char buf[4000]; ptrdiff_t size = sizeof buf; ptrdiff_t size_max = STRING_BYTES_BOUND + 1; - char const *m_end = m + strlen (m); char *buffer = buf; ptrdiff_t used; Lisp_Object string; - while (1) - { - va_list ap_copy; - va_copy (ap_copy, ap); - used = doprnt (buffer, size, m, m_end, ap_copy); - va_end (ap_copy); - - /* Note: the -1 below is because `doprnt' returns the number of bytes - excluding the terminating null byte, and it always terminates with a - null byte, even when producing a truncated message. */ - if (used < size - 1) - break; - if (size <= size_max / 2) - size *= 2; - else if (size < size_max) - size = size_max; - else - break; /* and leave the message truncated */ - - if (buffer != buf) - xfree (buffer); - buffer = (char *) xmalloc (size); - } - + used = evxprintf (&buffer, &size, buf, size_max, m, ap); string = make_string (buffer, used); if (buffer != buf) xfree (buffer);